﻿import QtQuick 2.6
import QtQuick.Controls 2.2
import QtQuick.Layouts 1.3

Button {
    property alias icon: icon.source
    property color iconColor: "#54626f"
    property color iconHighlightColor: "#dcdcdc"
    property color iconHoveredBgColor: "#1d2025"
    property color iconPressedBgColor: "#1d2025"
    property color iconBgColor: "transparent"
    property alias strText: title.text
    property bool bHighlighted: false
    id: control
    background: Rectangle
                {
                    color: control.hovered ? (control.pressed ? iconHoveredBgColor : iconPressedBgColor) :  (bHighlighted ? iconHoveredBgColor : iconBgColor);
                    border.width: control.hovered || bHighlighted ? 4 : 0;
                    border.color: "#029fea"

                    // 使用矩形覆盖上层Rectangle的边框
                    Rectangle {
                        color: parent.color
                        border.width: 0
                        anchors.fill: parent
                        // 使用Margin来确定是否显示边框
                        anchors.leftMargin: 4
                        anchors.topMargin: 0
                        anchors.rightMargin: 0
                        anchors.bottomMargin: 0
                    }
                }

    contentItem: Item {
        RowLayout {
            spacing: 6
            anchors.fill: parent
            anchors.leftMargin: 6
            IconFont {
                id: icon
                width: 9
                height: 9
                color: control.hovered || bHighlighted ? iconHighlightColor : iconColor
            }
            Text {
                id: title
                color: control.hovered || bHighlighted ? iconHighlightColor : iconColor;
                font.pixelSize: 12
                Layout.fillWidth: true

            }
        }
    }
}
